home *** CD-ROM | disk | FTP | other *** search
- //-------------------------------------------------------------------//
-
- // Synopsis: Matrix whose columns repeat cyclically.
-
- // Syntax: A = cycol ( [M, N] , K )
-
- // Descriptioin:
-
- // A is an M-by-N matrix of the form A = B[1:M;1:N] where
- // B = [C, C, C,...] and C = RAND(M, K) (normal
- // distribution). Thus A's columns repeat cyclically, and A has
- // rank at most K. K need not divide N. K defaults to
- // ROUND(N/4). CYCOL(N, K), where N is a scalar, is
- // the same as CYCOL([N, N], K).
-
- // This type of matrix can lead to underflow problems for Gaussian
- // elimination: see NA Digest Volume 89, Issue 3 (January 22, 1989).
-
- // This file is a translation of cycol.m from version 2.0 of
- // "The Test Matrix Toolbox for Matlab", described in Numerical
- // Analysis Report No. 237, December 1993, by N. J. Higham.
-
- //-------------------------------------------------------------------//
-
- cycol = function ( n , k )
- {
- local (n, k)
-
- m = n[1]; // Parameter n specifies dimension: m-by-n.
- n = n[max(size(n))];
-
- if (!exist (k)) { k = max(round(n/4),1); }
-
- rand("normal", 0, 1);
- A = rand(m, k);
- for (i in 2:ceil(n/k))
- {
- A = [A, A[;1:k]];
- }
-
- A = A[;1:n];
- return A;
- };
-